//======================================================================================================================
// 2007 Copyright Mystic Lake Software
//
// This file is part of The Ham Radio Network.
//
// The Ham Radio Network is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// The Ham Radio Network is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//======================================================================================================================
//
//     Author: Rudyard Merriam
//
//      $Id: member_fun.h 6 2007-10-04 07:01:34Z k5rud@arrl.net $
//
//======================================================================================================================
#if !defined member_fun_Include
#define member_fun_Include
//----------------------------------------------------------------------------------------------------------------------
template <typename  R, typename  T, typename  P> 
class member_func_t : public unary_function<P,R> 
{
public:
    explicit member_func_t(T& type, R (T::*func)(P)) 
    {
        mClass = &type;
        mFunc = func;
    };
    R operator()(P param) { return (mClass->*(mFunc))(param); };

protected:
    T* mClass;
    R (T::*mFunc)(P);
};
//----------------------------------------------------------------------------------------------------------------------
template <typename R, typename  T, typename  P>
member_func_t<R,T,P> member_fun(T& type, R (T::*func)(P)) 
{
    return member_func_t<R, T, P>(type, func);
}

#endif // member_fun_Include
